/*
 * @Author: jianghaiyang807
 * @Date:   2016-10-27
 */

import {
  WE_CHAT_SHOW,
  WE_CHAT_HIDE,
  TOGGLE_NAV,
  TOGGLE_BENEFNO,
  SHOW_TELTIPS,
  HIDE_TELTIPS,
  TOGGLE_AGREEMENT,
  TOGGLE_APPLY
} from 'actions'
import { isIos, isAndroid, isWx} from 'config'

const state = {
  // 产品介绍
  homeData: {
    navLists: [
      {
        name: '客户校验',
        dir: 'left',
        active: true
      },
      {
        name: '产品介绍',
        dir: 'center',
        active: false
      },
      {
        name: '投保案例',
        dir: 'right',
        active: false
      }
    ],
    cardTypeItems: [
      {
        name: '身份证',
        'val': 1
      },
      {
        name: '护照',
        'val': 2
      },
      {
        name: '军人证',
        'val': 3
      },
      {
        name: '户口本',
        'val': 0
      },
      {
        name: '港澳台证件',
        'val': 6
      },
      {
        name: '出生证',
        'val': 'A'
      }
    ],
    showWeChatSwitch: false,
    activeDir: 'left',
    isLoading: false
  },

  // 投保确认页面
  insureData: {
    telTips: false,
    agreement: false,
    apply: false,
    smsCodeCount: 5,
    smsCodeText: '获取验证码',
    smsCodeClassFlag: false,
    benefitFlag: 0, //后续需填充到formData中
    benefnos: [
      { active: true, val: 0, name: '法定' },
      { active: false, val: 1, name: '指定' }
    ]
  },

  // 投保结果
  resultData: {}
}


const mutations = {
  [WE_CHAT_SHOW](state) {
    state.homeData.showWeChatSwitch = true
  },
  [WE_CHAT_HIDE](state) {
    state.homeData.showWeChatSwitch = false
  },
  [TOGGLE_NAV](state, index) {
    state.homeData.navLists.forEach(item => {
      item.active = false
    })
    state.homeData.activeDir = state.homeData.navLists[index].dir
    state.homeData.navLists[index].active = true
  }
  ,[TOGGLE_BENEFNO](state, index) {
    state.insureData.benefnos.forEach(item => {
      item.active = false
    })
    let cur = state.insureData.benefnos[index]
    cur.active = true
    state.insureData.benefitFlag = cur.val
  }
  ,[SHOW_TELTIPS](state) {
    state.insureData.telTips = true
  }
  ,[HIDE_TELTIPS](state) {
    state.insureData.telTips = false
  }
  ,[TOGGLE_AGREEMENT](state) {
    state.insureData.agreement = !state.insureData.agreement
  }
  ,[TOGGLE_APPLY](state) {
    state.insureData.apply = !state.insureData.apply
  }
}

export default {
  state,
  mutations
}
